<?php
/**
 * Mechanism
 * 
 * LICENSE
 * 
 * This file is private intellectual property of the author. 
 * All rights reserved. Copying and illegal using is punishable by law.
 * 
 * @copyright Copyright (c) 2011 BreatheInMyVoid ( BreatheInMyVoid@gmail.com )
 */

 namespace Mechanism\Request {
 	/**
 	 * Http request
 	 * 
	 * @package Mechanism
	 * @author BreatheInMyVoid ( BreatheInMyVoid@gmail.com )
 	 */
 	class Http extends Request {
		/**
		 * 
		 */
 	 	public function get_get( $key = null, $default = null ) {
 			return ( isset( $_GET[$key] ) ) ?
 				$_GET[$key] : $default;
		}	

 		/**
 		 * 
 		 */
 	 	public function get_post( $key = null, $default = null ) {
 			return ( isset( $_POST[$key] ) ) ?
 				$_POST[$key] : $default;
 		}		
 		
 		/**
 		 * 
 		 */
 	 	public function get_cookie( $key = null, $default = null ) {
 			return ( isset( $_COOKIE[$key] ) ) ?
 				$_COOKIE[$key] : $default;
 		}
 		
 	 	/**
 		 * 
 		 */
 	 	public function get_server( $key = null, $default = null ) {
 			return ( isset( $_SERVER[$key] ) ) ? 
 				$_SERVER[$key] : $default;
 		}
 
 		/**
 		 * 
 		 */
 	 	public function get_env( $key = null, $default = null ) {
 			return ( isset( $_ENV[$key] ) ) ? 
 				$_ENV[$key] : $default;
 		}

 		/**
 		 * 
 		 */
 		public function get_method( ) {
 			return $this->get_server( 'REQUEST_METHOD' );
 		}
 		
 		/**
 		 * 
 		 */
 		public function get_header( ) {
 			
 		}
 		
 	 	/**
 		 * 
 		 */
 		public function get_client_ip( ) {
			/* Check proxy first */
 			if ( null !== $this->get_server( 'HTTP_CLIENT_IP') ) {
 				return $this->get_server( 'HTTP_CLIENT_IP' );
 			} else if ( null !== $this->get_server( 'HTTP_X_FORWARDED_FOR' ) ) {
 				return $this->get_server( 'HTTP_X_FORWARDED_FOR');
 			} else {
 				return $this->get_server( 'REMOTE_ADDR' );
 			}		
 		} 	

 	 	/**
 		 * 
 		 */
 		public function set_get( $key, $value ) {
 			$_GET[$key] = $value;
 		}
 		
 		/**
 		 * 
 		 */
 		public function set_post( $key, $value ) {
 			$_POST[$key] = $value;
 		}

 		/**
 		 * 
 		 */
 		public function is_get( ) {
 			return ( 'GET' === $this->get_method( ) ) ?
 				true : false;
 		}
 		
 		/**
 		 * 
 		 */
 		public function is_post( ) {
 			return ( 'POST' === $this->get_method( ) ) ?
 				true : false;
 		} 		
 		
 	 	/**
 		 * 
 		 */
 		public function is_put( ) {
 			return ( 'PUT' === $this->get_method( ) ) ?
 				true : false;
 		}		
 		
 	 	/**
 		 * 
 		 */
 		public function is_delete( ) {
 			return ( 'DELETE' === $this->get_method( ) ) ?
 				true : false;
 		}		
 		
 	 	/**
 		 * 
 		 */
 		public function is_head( ) {
 			return ( 'HEAD' === $this->get_method( ) ) ?
 				true : false;
 		}
 		
 	 	/**
 		 * 
 		 */
 		public function is_options( ) {
 			return ( 'OPTIONS' === $this->get_method( ) ) ?
 				true : false;
 		}		
 		
 		/**
 		 * 
 		 */
 		public function is_ajax( ) {
 			
 		}
 		
 	 	/**
 		 * 
 		 */
 		public function is_flash( ) {
 			
 		}		
 		
 	 	/**
 		 * 
 		 */
 		public function is_sequre( ) {
 			
 		}	 				
 	}
 }
